import os
import sys
import django
import xlrd

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.extend([BASE_DIR, ])
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "finance_c2c.settings")
django.setup()

from apps.supply_order.models import Goods


def insert_goods(xlsx):
    data = xlrd.open_workbook(xlsx)  # 打开excel
    table = data.sheets()[0]
    rows = table.nrows  # 行数

    for i in range(1, 2):
        row_values = table.row_values(i)  # 某一行数据
        print(row_values[1])
        # province_name = row_values[0]
        # province = Province.objects.get(name__contains=province_name)

        # goods_type = GoodsType.objects.get(goods_type=goods_type)


if __name__ == '__main__':
    insert_goods("insert_goods.xlsx")
